﻿using System;
using System.Collections.Generic;
using System.Data;
using System.Data.SqlClient;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

namespace HZ_TEST001
{
    public partial class Email : System.Web.UI.Page
    {
        string conString = "Data Source=(localdb)\\Projects;Initial Catalog=HZ_Message;Integrated Security=True;Connect Timeout=30;Encrypt=False;TrustServerCertificate=False";

        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                BindGridView();
            } 
        }

        private void BindGridView()
        {
            SqlConnection con = new SqlConnection(conString);

            con.Open();
            SqlCommand cmd = new SqlCommand("select [Date],[Name],[message],[read],[reply] from dbo.id1;", con);
            SqlDataAdapter adp = new SqlDataAdapter(cmd);
            DataSet ds = new DataSet();
            adp.Fill(ds);
            this.GridView1.DataSource = ds;
            
            this.GridView1.DataBind();
            
            con.Close();  
        }
        protected void Button1_Click(object sender, EventArgs e)
        {
            Response.Redirect("NewEmail.aspx");
        }

        protected void Button1_Click1(object sender, EventArgs e)
        {

        }

        protected void gdDelete(object sender, GridViewCommandEventArgs e)
        {

        }
    }
}